<?php
/**
 * StatZone default view
 * 
 * @package    USS.StatZone
 * @subpackage Components
 * @link www.ugenix.co.za www.statzone.co.za
 * @license		Commercial
 * @author Salie Hendricks
 */


// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();

jimport( 'joomla.application.component.view' );

/**
 * Settings View
 *
 * @package    USS.StatZone
 * @subpackage Components
 */
class StatZoneViewSettings extends JView
{
    
    function setSettingsToolbar()
	{
		$task = JRequest::getVar( 'task', '', 'method', 'string');

        JToolBarHelper::title(   JText::_( 'StatZone Settings Manager' ), 'generic.png' );
		JToolBarHelper::save( 'save' );
		JToolBarHelper::apply('apply');
		JToolBarHelper::cancel( 'cancel' );

	}
    
	function settings2( &$row)
	{
		StatZoneViewSettings::setSettingsToolbar();
		JRequest::setVar( 'hidemainmenu', 1 );
        ?>
		<script language="javascript" type="text/javascript">
		<!--
		
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}
			// do field validation
			if (form.sectionid.value == "") {
				alert( "<?php echo JText::_( 'You must provide a section id.', true ); ?>" );
			} 
			else if ( getSelectedValue('adminForm','clubid') == 0 ) {
				alert( "<?php echo JText::_( 'Please select a club.', true ); ?>" );
			} 
          else {
				submitform( pressbutton );
			}
		}
		//-->
		</script>
		<form action="index.php" method="post" name="adminForm">

		<div class="col100">
			<fieldset class="adminform">
				<legend><?php echo JText::_( 'Settings' ); ?></legend>

				<table class="admintable">
				<tbody>
					<tr>
						<td width="20%" class="key">
							<label for="name">
								<?php echo JText::_( 'Name' ); ?>:
							</label>
						</td>
						<td width="80%">
							<input class="inputbox" type="text" name="name" id="name" size="50" value="<?php echo $row->name;?>" />
						</td>
					</tr>
					<tr>
						<td width="20%" class="key">
							<label for="alias">
								<?php echo JText::_( 'Province' ); ?>:
							</label>
						</td>
						<td width="80%">
							<?php echo $lists['provinceid']; ?>
						</td>
					</tr>
                    <tr>
						<td width="20%" class="key">
							<label for="alias">
								<?php echo JText::_( 'Club' ); ?>:
							</label>
						</td>
						<td width="80%">
							<?php echo $lists['clubid']; ?>
						</td>
					</tr>
                    <tr>
						<td width="20%" class="key">
							<label for="alias">
								<?php echo JText::_( 'Description' ); ?>:
							</label>
						</td>
						<td width="80%">
							<textarea class="inputbox" cols="70" rows="8" name="description" id="description"><?php echo $row->description;?></textarea>
						</td>
					</tr>
				</tbody>
				</table>
			</fieldset>
		</div>
		<div class="clr"></div>

		<input type="hidden" name="c" value="team" />
		<input type="hidden" name="option" value="com_statzone" />
		<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
		<input type="hidden" name="task" value="" />
		<?php echo JHTML::_( 'form.token' ); ?>
		</form>
		<?php
	}
    
    //
    //View display function to view the list settings
    //
    function settings( &$rows)
    {
        StatZoneViewSettings::setSettingsToolbar();
        $user =& JFactory::getUser();
		JHTML::_('behavior.tooltip');
        ?>
		<form action="index.php?option=com_statzone" method="post" name="adminForm">
		

        <table class="adminlist">
			<thead>
				<tr>
					<th nowrap="nowrap" width="40%" class="title">
						<?php echo JHTML::_('grid.sort',  'Name', 's.name', @$lists['order_Dir'], @$lists['order'] ); ?>
					</th>
					<th width="40%" nowrap="nowrap">
						<?php echo JHTML::_('grid.sort',   'Value', 's.value', @$lists['order_Dir'], @$lists['order'] ); ?>
					</th>
					<th width="1%" nowrap="nowrap">
						<?php echo JHTML::_('grid.sort',   'ID', 's.id', @$lists['order_Dir'], @$lists['order'] ); ?>
					</th>
				</tr>
			</thead>
			<tbody>
            
			<?php
            $k = 0;
			for ($i=0, $n=count( $rows ); $i < $n; $i++) {
				$row = &$rows[$i];

				$row->id	= $row->id;
				
                ?>
				<tr class="<?php echo "row$k"; ?>">
					<td align="left">
						<?php echo $row->name;?>
                        
					</td>
					<td align="center">
						<input class="inputbox" type="text" name="<?php echo $row->name;?>" id="name" size="50" value="<?php echo $row->value;?>" />
					</td>
					<td align="center">
						<?php echo $row->id; ?>
					</td>
				</tr>
				<?php
				$k = 1 - $k;
			}
			?>
            
			</tbody>
			</table>

		<input type="hidden" name="c" value="setting" />
		<input type="hidden" name="option" value="com_statzone" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />
		<?php echo JHTML::_( 'form.token' ); ?>
		</form>
		<?php
    }
}
